<template>
  <div class="searchEngineBox">
    <el-tabs v-model="activeName">
      <!-- for tabs -->
      <el-tab-pane v-for="tab in tabs" :key="tab.tabIndex" :name="tab.tabName">
        <span slot="label" class="tab-title">
          {{tab.tabName}}
          <i class="tag-right">{{tab.tabTotal}}</i>
        </span>
        <tab-config
          :configs="tab.config"
          :state="tab.state"
          :tabIndex="tab.tabIndex"
          @setTotal="setTotal"
        />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import tabConfig from './tabConfig';
export default {
  name: 'searchEngineTabs',
  components: {
    tabConfig
  },
  // case|police|keyPerson|offenMan|leaveMan
  data() {
    return {
      activeName: '案件',
      tabs: [
        {
          tabName: '案件', tabIndex: 0, tabTotal: 3,
          config: [
            {
              component: 'popRange',
              title: '报警时间',
              visible: false,
              data: ''
            },
            {
              component: 'dropdown',
              title: '案件性质',
              items: ['黄金糕', '黄金糕2', '黄金糕3'],
              visible: false,
              data: ''
            },
            {
              component: 'popInput',
              title: '描述',
              visible: false,
              data: '',
              placeholder: '输入的描述信息'
            }
          ], state: 'case'
        },
        {
          tabName: '接处警', tabIndex: 1, tabTotal: 5,
          config: [
            {
              component: 'popRange',
              title: '接处警',
              visible: false,
              data: ''
            },
            {
              component: 'dropdown',
              title: '接处警案件性质',
              items: ['黄金糕', '黄金糕2', '黄金糕3'],
              visible: false,
              data: ''
            }
          ], state: 'police'
        },
        {
          tabName: '重点人员', tabIndex: 2, tabTotal: 7,
          config: [{
            component: 'popRange',
            title: '重点人员',
            visible: false,
            data: ''
          }], state: 'keyPerson'
        },
        {
          tabName: '常口', tabIndex: 3, tabTotal: 9,
          config: [{
            component: 'popRange',
            title: '常口',
            visible: false,
            data: ''
          }], state: 'offenMan'
        },
        {
          tabName: '暂口', tabIndex: 4, tabTotal: 78,
          config: [], state: 'leaveMan'
        }
      ]
    };
  },
  methods: {
    setTotal(data) {
      let { index, val } = data;
      console.log(index + ' ' + val);
      this.tabs[index].tabTotal = val;
    }
  }
};
</script>
<style lang="scss" scoped>
.tab-title {
  position: relative;
  .tag-right {
    font-style: normal;
    font-size: 12px;
    text-decoration: none;
    position: absolute;
    // right: 0;
    top: -10px;
    width: auto;
    height: 15px;
    padding: 0 2px;
    border: 1px solid #333;
    border-radius: 50%;
    text-align: center;
    line-height: 15px;
  }
}
</style>
<style lang="scss">
.searchEngineBox {
  .list-item {
    color: #333;
    span {
      margin-right: 10px;
      line-height:24px;
    }
  }
}
</style>
